import vpd from '../mixins/vpd';
import sysDataSource from '../../dataSource';

let dataSources;

const install = (Vue, config = {}) => {
  if (install.installed) return;

  dataSources = Object.assign({}, sysDataSource, config.dataSources);

  Object.keys(dataSources).forEach(key => {
    Vue.component(key, dataSources[key]);
    Vue.component(key, Vue.extend(dataSources[key]).extend(vpd));
  })
};

export default {
  install,
  getDataSources() {
    return dataSources
  }
}
